# 导包
import config
from api.login import LoginAPI
from common.assertutil import common_assert
from common.readjsonutil import build_data
import pytest


# 创建测试类
class TestLoginAPI:
    # 前置处理
    def setup(self):
        # 实例化接口类
        self.login_api = LoginAPI()

    # 后置处理
    def teardown(self):
        pass

    # 登录
    # @pytest.mark.parametrize("测试数据对应个数的变量名", 测试数据)
    # def test01_login(self, 测试数据对应个数的变量名):
    @pytest.mark.parametrize("login_data, status_code, success, code, message", build_data(config.BASE_PATH + "/data/login.json"))
    def test01_login(self, login_data, status_code, success, code, message):
        response = self.login_api.login(login_data)
        common_assert(response, status_code, success, code, message)

